{template 'common/header'}
<ul class="nav nav-tabs">
    <li
    {if $op =='post' && empty($id)}class="active"{/if}><a
        href="{php echo $this->createWebUrl('hdp', array('op' => 'post'));}">添加幻灯片</a>
    </li>
    <li
    {if $op =='display'}class="active"{/if}><a href="{php echo $this->createWebUrl('hdp',array('op'=>'display'));}">管理幻灯片</a>
    </li>
    {if !empty($id) && $op == 'post'}
    <li class="active">
        <a href="{php echo $this->createWebUrl('hdp',array('op'=>'post','id'=>$id));}">编辑幻灯片</a>
    </li>
    {/if}
</ul>

<style>
    .table td span {
        display: inline-block;
        margin-top: 4px;
    }

    .table td input {
        margin-bottom: 0;
    }
</style>
{if $op == 'display'}
<div style="padding:15px;">
    <form id="form2" class="form-horizontal" method="post">
        <table class="table">
            <thead>
            <tr>
                <th style="width:100px;">排序</th>
                <th>链接</th>
                <th>图片</th>
                <th style="text-align:right;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $item}
            <tr>
                <td class="text-center">
                    <input type="text" class="form-control" name="displayorder[{$item['id']}]" value="{$item['displayorder']}">
                </td>
                <td>
                     {$item['followurl']}
                </td>
                <td>
                    <img src="{php echo strpos($item['thumb'],'http://')===FALSE?($_W['attachurl'].$item['thumb']):$item['thumb']}" style="width: 150px;height: 50px;" />
                </td>
                <td style="text-align:right;">
                    <a href="{php echo $this->createWebUrl('hdp', array('op' => 'post', 'id' => $item['id']))}" title="编辑" data-toggle="tooltip" data-placement="top" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>
                    </a>
                    <a onclick="return confirm('此操作不可恢复，确认吗？'); return false;"
                       href="{php echo $this->createWebUrl('hdp', array('op' => 'delete', 'id' => $item['id']))}"
                       title="删除" data-toggle="tooltip" data-placement="top" class="btn btn-default btn-sm"><i class="fa fa-times"></i></a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        <div class="form-group col-sm-12">
            <input name="submit" type="submit" class="btn btn-primary col-lg-1" value="更新排序">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </form>
</div>
<script type="text/javascript">
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>
{elseif $op == 'post'}
<div class="clearfix">
    <form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">广告管理</div>
            <div class="panel-body">
                <input type="hidden" name="id" value="{$item[id]}">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">排序</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                    </div>
                </div>
                <div class="form-group" >
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">链接</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="followurl" class="form-control" value="{$item['followurl']}" />                       
                    </div>
                </div>

                <div class="form-group define-icon">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传图标</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('thumb', $item['thumb']);}
                    </div>
                </div>

            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
                <input type="hidden" name="token" value="{$_W['token']}"/>
            </div>
        </div>
    </form>
</div>
{/if}